package b.i.l;

import android.view.ActionMode;
import android.view.ActionMode.Callback;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;
import java.lang.reflect.Method;

/* compiled from: TextViewCompat */
public class d implements Callback {
    public final Callback a;
    public final TextView b;
    public Class<?> c;
    public Method d;
    public boolean e;
    public boolean f = false;

    public d(Callback callback, TextView textView) {
        this.a = callback;
        this.b = textView;
    }

    public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) {
        return this.a.onActionItemClicked(actionMode, menuItem);
    }

    public boolean onCreateActionMode(ActionMode actionMode, Menu menu) {
        return this.a.onCreateActionMode(actionMode, menu);
    }

    public void onDestroyActionMode(ActionMode actionMode) {
        this.a.onDestroyActionMode(actionMode);
    }

    /* JADX WARNING: Removed duplicated region for block: B:63:0x009f A:{SYNTHETIC} */
    /* JADX WARNING: Removed duplicated region for block: B:41:0x00d1  */
    /* JADX WARNING: Missing block: B:37:0x00c9, code skipped:
            if (r0.checkSelfPermission(r9) != 0) goto L_0x00cc;
     */
    public boolean onPrepareActionMode(android.view.ActionMode r13, android.view.Menu r14) {
        /*
        r12 = this;
        r0 = r12.b;
        r0 = r0.getContext();
        r1 = r0.getPackageManager();
        r2 = r12.f;
        r3 = "removeItemAt";
        r4 = 1;
        r5 = 0;
        if (r2 != 0) goto L_0x0032;
    L_0x0012:
        r12.f = r4;
        r2 = "com.android.internal.view.menu.MenuBuilder";
        r2 = java.lang.Class.forName(r2);	 Catch:{ ClassNotFoundException | NoSuchMethodException -> 0x002b, ClassNotFoundException | NoSuchMethodException -> 0x002b }
        r12.c = r2;	 Catch:{ ClassNotFoundException | NoSuchMethodException -> 0x002b, ClassNotFoundException | NoSuchMethodException -> 0x002b }
        r6 = new java.lang.Class[r4];	 Catch:{ ClassNotFoundException | NoSuchMethodException -> 0x002b, ClassNotFoundException | NoSuchMethodException -> 0x002b }
        r7 = java.lang.Integer.TYPE;	 Catch:{ ClassNotFoundException | NoSuchMethodException -> 0x002b, ClassNotFoundException | NoSuchMethodException -> 0x002b }
        r6[r5] = r7;	 Catch:{ ClassNotFoundException | NoSuchMethodException -> 0x002b, ClassNotFoundException | NoSuchMethodException -> 0x002b }
        r2 = r2.getDeclaredMethod(r3, r6);	 Catch:{ ClassNotFoundException | NoSuchMethodException -> 0x002b, ClassNotFoundException | NoSuchMethodException -> 0x002b }
        r12.d = r2;	 Catch:{ ClassNotFoundException | NoSuchMethodException -> 0x002b, ClassNotFoundException | NoSuchMethodException -> 0x002b }
        r12.e = r4;	 Catch:{ ClassNotFoundException | NoSuchMethodException -> 0x002b, ClassNotFoundException | NoSuchMethodException -> 0x002b }
        goto L_0x0032;
    L_0x002b:
        r2 = 0;
        r12.c = r2;
        r12.d = r2;
        r12.e = r5;
    L_0x0032:
        r2 = r12.e;	 Catch:{ IllegalAccessException | NoSuchMethodException | InvocationTargetException -> 0x0129, IllegalAccessException | NoSuchMethodException | InvocationTargetException -> 0x0129, IllegalAccessException | NoSuchMethodException | InvocationTargetException -> 0x0129 }
        if (r2 == 0) goto L_0x0041;
    L_0x0036:
        r2 = r12.c;	 Catch:{ IllegalAccessException | NoSuchMethodException | InvocationTargetException -> 0x0129, IllegalAccessException | NoSuchMethodException | InvocationTargetException -> 0x0129, IllegalAccessException | NoSuchMethodException | InvocationTargetException -> 0x0129 }
        r2 = r2.isInstance(r14);	 Catch:{ IllegalAccessException | NoSuchMethodException | InvocationTargetException -> 0x0129, IllegalAccessException | NoSuchMethodException | InvocationTargetException -> 0x0129, IllegalAccessException | NoSuchMethodException | InvocationTargetException -> 0x0129 }
        if (r2 == 0) goto L_0x0041;
    L_0x003e:
        r2 = r12.d;	 Catch:{ IllegalAccessException | NoSuchMethodException | InvocationTargetException -> 0x0129, IllegalAccessException | NoSuchMethodException | InvocationTargetException -> 0x0129, IllegalAccessException | NoSuchMethodException | InvocationTargetException -> 0x0129 }
        goto L_0x004f;
    L_0x0041:
        r2 = r14.getClass();	 Catch:{ IllegalAccessException | NoSuchMethodException | InvocationTargetException -> 0x0129, IllegalAccessException | NoSuchMethodException | InvocationTargetException -> 0x0129, IllegalAccessException | NoSuchMethodException | InvocationTargetException -> 0x0129 }
        r6 = new java.lang.Class[r4];	 Catch:{ IllegalAccessException | NoSuchMethodException | InvocationTargetException -> 0x0129, IllegalAccessException | NoSuchMethodException | InvocationTargetException -> 0x0129, IllegalAccessException | NoSuchMethodException | InvocationTargetException -> 0x0129 }
        r7 = java.lang.Integer.TYPE;	 Catch:{ IllegalAccessException | NoSuchMethodException | InvocationTargetException -> 0x0129, IllegalAccessException | NoSuchMethodException | InvocationTargetException -> 0x0129, IllegalAccessException | NoSuchMethodException | InvocationTargetException -> 0x0129 }
        r6[r5] = r7;	 Catch:{ IllegalAccessException | NoSuchMethodException | InvocationTargetException -> 0x0129, IllegalAccessException | NoSuchMethodException | InvocationTargetException -> 0x0129, IllegalAccessException | NoSuchMethodException | InvocationTargetException -> 0x0129 }
        r2 = r2.getDeclaredMethod(r3, r6);	 Catch:{ IllegalAccessException | NoSuchMethodException | InvocationTargetException -> 0x0129, IllegalAccessException | NoSuchMethodException | InvocationTargetException -> 0x0129, IllegalAccessException | NoSuchMethodException | InvocationTargetException -> 0x0129 }
    L_0x004f:
        r3 = r14.size();	 Catch:{ IllegalAccessException | NoSuchMethodException | InvocationTargetException -> 0x0129, IllegalAccessException | NoSuchMethodException | InvocationTargetException -> 0x0129, IllegalAccessException | NoSuchMethodException | InvocationTargetException -> 0x0129 }
        r3 = r3 - r4;
    L_0x0054:
        r6 = "android.intent.action.PROCESS_TEXT";
        if (r3 < 0) goto L_0x007e;
    L_0x0058:
        r7 = r14.getItem(r3);	 Catch:{ IllegalAccessException | NoSuchMethodException | InvocationTargetException -> 0x0129, IllegalAccessException | NoSuchMethodException | InvocationTargetException -> 0x0129, IllegalAccessException | NoSuchMethodException | InvocationTargetException -> 0x0129 }
        r8 = r7.getIntent();	 Catch:{ IllegalAccessException | NoSuchMethodException | InvocationTargetException -> 0x0129, IllegalAccessException | NoSuchMethodException | InvocationTargetException -> 0x0129, IllegalAccessException | NoSuchMethodException | InvocationTargetException -> 0x0129 }
        if (r8 == 0) goto L_0x007b;
    L_0x0062:
        r7 = r7.getIntent();	 Catch:{ IllegalAccessException | NoSuchMethodException | InvocationTargetException -> 0x0129, IllegalAccessException | NoSuchMethodException | InvocationTargetException -> 0x0129, IllegalAccessException | NoSuchMethodException | InvocationTargetException -> 0x0129 }
        r7 = r7.getAction();	 Catch:{ IllegalAccessException | NoSuchMethodException | InvocationTargetException -> 0x0129, IllegalAccessException | NoSuchMethodException | InvocationTargetException -> 0x0129, IllegalAccessException | NoSuchMethodException | InvocationTargetException -> 0x0129 }
        r6 = r6.equals(r7);	 Catch:{ IllegalAccessException | NoSuchMethodException | InvocationTargetException -> 0x0129, IllegalAccessException | NoSuchMethodException | InvocationTargetException -> 0x0129, IllegalAccessException | NoSuchMethodException | InvocationTargetException -> 0x0129 }
        if (r6 == 0) goto L_0x007b;
    L_0x0070:
        r6 = new java.lang.Object[r4];	 Catch:{ IllegalAccessException | NoSuchMethodException | InvocationTargetException -> 0x0129, IllegalAccessException | NoSuchMethodException | InvocationTargetException -> 0x0129, IllegalAccessException | NoSuchMethodException | InvocationTargetException -> 0x0129 }
        r7 = java.lang.Integer.valueOf(r3);	 Catch:{ IllegalAccessException | NoSuchMethodException | InvocationTargetException -> 0x0129, IllegalAccessException | NoSuchMethodException | InvocationTargetException -> 0x0129, IllegalAccessException | NoSuchMethodException | InvocationTargetException -> 0x0129 }
        r6[r5] = r7;	 Catch:{ IllegalAccessException | NoSuchMethodException | InvocationTargetException -> 0x0129, IllegalAccessException | NoSuchMethodException | InvocationTargetException -> 0x0129, IllegalAccessException | NoSuchMethodException | InvocationTargetException -> 0x0129 }
        r2.invoke(r14, r6);	 Catch:{ IllegalAccessException | NoSuchMethodException | InvocationTargetException -> 0x0129, IllegalAccessException | NoSuchMethodException | InvocationTargetException -> 0x0129, IllegalAccessException | NoSuchMethodException | InvocationTargetException -> 0x0129 }
    L_0x007b:
        r3 = r3 + -1;
        goto L_0x0054;
    L_0x007e:
        r2 = new java.util.ArrayList;
        r2.<init>();
        r3 = r0 instanceof android.app.Activity;
        r7 = "text/plain";
        if (r3 != 0) goto L_0x008a;
    L_0x0089:
        goto L_0x00d5;
    L_0x008a:
        r3 = new android.content.Intent;
        r3.<init>();
        r3 = r3.setAction(r6);
        r3 = r3.setType(r7);
        r3 = r1.queryIntentActivities(r3, r5);
        r3 = r3.iterator();
    L_0x009f:
        r8 = r3.hasNext();
        if (r8 == 0) goto L_0x00d5;
    L_0x00a5:
        r8 = r3.next();
        r8 = (android.content.pm.ResolveInfo) r8;
        r9 = r0.getPackageName();
        r10 = r8.activityInfo;
        r10 = r10.packageName;
        r9 = r9.equals(r10);
        if (r9 == 0) goto L_0x00ba;
    L_0x00b9:
        goto L_0x00ce;
    L_0x00ba:
        r9 = r8.activityInfo;
        r10 = r9.exported;
        if (r10 != 0) goto L_0x00c1;
    L_0x00c0:
        goto L_0x00cc;
    L_0x00c1:
        r9 = r9.permission;
        if (r9 == 0) goto L_0x00ce;
    L_0x00c5:
        r9 = r0.checkSelfPermission(r9);
        if (r9 != 0) goto L_0x00cc;
    L_0x00cb:
        goto L_0x00ce;
    L_0x00cc:
        r9 = 0;
        goto L_0x00cf;
    L_0x00ce:
        r9 = 1;
    L_0x00cf:
        if (r9 == 0) goto L_0x009f;
    L_0x00d1:
        r2.add(r8);
        goto L_0x009f;
    L_0x00d5:
        r0 = 0;
    L_0x00d6:
        r3 = r2.size();
        if (r0 >= r3) goto L_0x0129;
    L_0x00dc:
        r3 = r2.get(r0);
        r3 = (android.content.pm.ResolveInfo) r3;
        r8 = r0 + 100;
        r9 = r3.loadLabel(r1);
        r8 = r14.add(r5, r5, r8, r9);
        r9 = r12.b;
        r10 = new android.content.Intent;
        r10.<init>();
        r10 = r10.setAction(r6);
        r10 = r10.setType(r7);
        r11 = r9 instanceof android.text.Editable;
        if (r11 == 0) goto L_0x010d;
    L_0x00ff:
        r11 = r9.onCheckIsTextEditor();
        if (r11 == 0) goto L_0x010d;
    L_0x0105:
        r9 = r9.isEnabled();
        if (r9 == 0) goto L_0x010d;
    L_0x010b:
        r9 = 1;
        goto L_0x010e;
    L_0x010d:
        r9 = 0;
    L_0x010e:
        r9 = r9 ^ r4;
        r11 = "android.intent.extra.PROCESS_TEXT_READONLY";
        r9 = r10.putExtra(r11, r9);
        r3 = r3.activityInfo;
        r10 = r3.packageName;
        r3 = r3.name;
        r3 = r9.setClassName(r10, r3);
        r3 = r8.setIntent(r3);
        r3.setShowAsAction(r4);
        r0 = r0 + 1;
        goto L_0x00d6;
    L_0x0129:
        r0 = r12.a;
        r13 = r0.onPrepareActionMode(r13, r14);
        return r13;
        */
        throw new UnsupportedOperationException("Method not decompiled: b.i.l.d.onPrepareActionMode(android.view.ActionMode, android.view.Menu):boolean");
    }
}
